define(function(require,exports,module) {
    var myPub = require('./public');
    // 广告模块
    var myAdsModel = require('./businessSubject_adsModels');
    // 地区管
    // var areaList = require('./areaList');

    var oWindow = $(window);
    var oWrap = $('.js_wrap');                      // wrap 部分
    var oHeader = $('.js_headerBox');               // 头部
    var oFooter = $('.js_footer');                  // 底部
    var oSearchBox = $('.js_searchBox');            // 搜索
    var oContain = $('.js_contain');                // 页面内容区域
    var oSlidePageWrap = $('.js_slidePageWrap');    // 滑动页面
    var oSlidePage = $('.js_slidePage');            // 滑动页面容器
    var oSideBox = $('.js_sideBox');		        // 侧边按钮框
    var oGoTop = $('.js_goTop');                    // 回到顶部
    var popCloseBtn=$('.js_layer_AdsCloseBtn')       //弹窗关闭按钮
    var oLoadingPage = $('.js_loadingPage');

    var oSildeNav = $('.js_sildeNav ');             // 导航栏
    var oSildeNavScroll = $('.js_sildeNavScroll');  // 导航滚动条容器
    var oSildeNavUl = $('.js_sildeNavUl');          // 导航滚动条ul

    var oSlidePageScroll = $('.js_slidePageScroll');
    var oSildeNavJRoll = new myPub.ScrollBar();     // 导航滚动条
    var nDisScrollLi = 0;                           // 导航滚动偏移值

    var oGoods_showTwo = $('.js_goods_showTwo');    // 并排产品容器

    var lazLoading = new myPub.lazLoadingImg();

    // var timeOutClock = null;  //返现专区跳转的定时器

    var perLimit = 20;
    var resizeTimer = null;
    var counponNewData = JSON.parse(sessionStorage.getItem('judgeNew_friend_coupons')); // 获取新人用户的优惠券数据
    // var nNewFriend = '';                                // 判断是不是新用户
    // nNewFriend = sessionStorage.getItem('judgeNew_friend');  // 新用户session的值
    // $('.guideShow').on("touchmove",function(e) {e.preventDefault();});
    // oHeader.on("touchmove",function(e) {e.preventDefault();});
    // oFooter.on("touchmove",function(e) {e.preventDefault();});

    var locationUrl = window.location.href;
    // 判断有没有app
    // myPub.isHasApp(locationUrl, locationUrl);

    // 回到过顶部
    oGoTop.hammer().on('tap',function() {
        var oSlidePageScroll = $('.js_slidePageScroll');
        oSlidePageScroll.eq(ajaxData.navIndex).stop().animate({scrollTop: '0'}, 250);
        oHeader.css({'top': 0}).find('.js_sildeNav').removeClass('active');
        myPub.HamstopPropaga();
    });

    // 关闭广告
    popCloseBtn.on('click',function(e) {
        $('.layer_Ads_index').hide();
        e.stopPropagation();
    });

    var categoryData, categoryNames;
    module.exports = {
        init:function(data,names){
            categoryData = data;
            categoryNames = names;

            // 生成新的滑动页面html
            // sfddjIndex.AppendSlidePage(names);

            // 初始化左右滑动swiper
            // sfddjIndex.SwiperSlide(names);

            // 初始化页面代码
            sfddjIndex.sfddjInit(true);

            // 历史记录初始化
            ajaxData.HistoryInit();

            // ajax请求前 锁定
            ajaxData.lockScroll();

            // 请求加载广告模块
            myAdsModel.adsAjax.AdsAjaxData(0, categoryNames);

            // 请求加载产品
            // ajaxData.GoodsAjaxData(0, true);

            // ajax请求后 解锁
            ajaxData.unlockScroll();

            // 设置页面滚动事件
            sfddjIndex.ScrollPage();

            // 倒计时
            myAdsModel.adsInit.CutDataTime();

            // 检测需不需要弹出新人优惠券
            // if(nNewFriend == 'newFriend'){
            //     // 弹出优惠券弹窗
            //     connectHtml.newFriendHtml();
            // }else{
            //     // 获取弹窗
            //     myAdsModel.adsAjax.getPop();
            // }

            // 产品懒加载  异步加载 调用这个
            lazLoading.AddLazLoadingImg(oSlidePageScroll[0]);

            // 页面尺寸修改
            oWindow.on('resize',function() {
                if (resizeTimer) {
                    clearTimeout(resizeTimer)
                }
                resizeTimer = setTimeout(function(){
                    sfddjIndex.sfddjInit(true);
                }, 400);

            });

            // 页面跳转记录数据
            oWindow.unload(function(){
                // ajaxData.SetSession();
            });
        }
    };


    var sfddjIndex = {
        // 页面swiper
        oSlidePageMain: '',
        nHeaderHeight: 0,
        nSearchBoxHeight: 0,
        nSildeNavHeight: 0,
        time_Scroll: null,           // 滚动计时器
        // 调整页面位置和初始化
        sfddjInit: function (bOff) {
            var oSlidePageScroll = $('.js_slidePageScroll');
            // bOff true 执行下面方法
            if(bOff) {
                // sfddjIndex.SetSildeNavScroll();
                oContain.css({
                    'padding-top': 0,
                    'padding-bottom' : 0

                });
                oSlidePageScroll.css({
                    'height': oWindow.height() - oHeader.height() - oFooter.height(),
                    'padding-top': oHeader.outerHeight(true),
                    'padding-bottom' : oFooter.outerHeight(true)
                });
                // myPub.SetImgHeight(oGoods_showTwo);
            }
            oHeader.css({'top': 0}).find('.js_sildeNav').removeClass('active');
            oSideBox.stop().animate({'right': '-3.5rem'},300);
        },

        // 插入slide
        AppendSlidePage: function (name) {
            var _className = '';
            var _advMainHtml = '<div class="AdvertMain jsAdvert"></div>'
            for(var i=0; i<name.length; i++) {

                // if(name[i].replace(/\s/g,"") == '地区馆') {
                //     _className = 'areaListBox';
                //     _advMainHtml = '<div class="areaList js_areaList"></div>';
                // }
                // if(name[i].replace(/\s/g,"") == '返现专区') {
                //
                //     _className = 'memberCashBack';
                //     _advMainHtml = '<div class="memberCashBackSon js_memberCashBack Height100"></div>';
                // }

                oSlidePageWrap.append('<div class="swiper-slide js_slidePageScroll '+ _className +'"><div class="slidePageMain js_slidePageMain">'+ _advMainHtml +'</div></div>');
                ajaxData.pagearr.push(1);
                ajaxData.tabLoadOff.push(true);
                ajaxData.pageSCroll.push(0);
                ajaxData.loadFinish.push(false);
            }
        },

        // 初始加载滑动页面和添加导航信息
        SwiperSlide: function (data) {
            var _this = this;
            _this.oSlidePageMain = oSlidePage.swiper({
                pagination: oSildeNavUl[0],
                observe: true,
                observeParents: true,
                // onlyExternal: true,
                //threshold:50,
                touchAngle:20,
                paginationClickable: true,
                paginationBulletRender:function(index,className){
                    //添加导航
                    index == 0 ? names = '推荐' : names = data[index-1].replace(/\s/g,"");
                    return '<li class="'+className+'"><a>'+ names +'</a></li>';
                },
                onSlideChangeStart:function (swiper) {
                    var index = swiper.activeIndex;
                    if(ajaxData.tabLoadOff[index]){
                        oLoadingPage.show();
                    }
                    // _this.oSlidePageMain.destroy(false);
                    _this.oSlidePageMain.detachEvents();
                },
                // 滑动结束
                onSlideChangeEnd: function (swiper) {
                    // console.log('我是在测试2')
                    var oSlidePageScroll = $('.js_slidePageScroll');
                    var index = swiper.activeIndex;
                    // 初始化页面 false 说明滚动不需要重置
                    sfddjIndex.sfddjInit(false);

                    // 同步滚动导航和页面滑动
                    _this.SildeNavScrollDis(index);

                    if(ajaxData.tabLoadOff[index]) {

                        // 地区馆添加
                        // if(oSlidePageScroll.eq(index).hasClass('areaListBox')) {
                        //     areaList.AreaListShow(function () {
                        //         oLoadingPage.hide();
                        //     });
                        // }
                        // //会员返现跳转
                        // else if(oSlidePageScroll.eq(index).hasClass('memberCashBack')){
                        //
                        //     oLoadingPage.hide()
                        //     // return
                        //     if(sessionStorage.getItem("navIndex") != null && sessionStorage.getItem("navIndex")*1 == index) {
                        //         sfddjIndex.SildeNavScrollDis(0, function() {
                        //             sfddjIndex.oSlidePageMain.slideTo(0, 100);
                        //         });
                        //         return;
                        //
                        //     }else {
                        //         //防止跳转后不执行下面的记录
                        //         oLoadingPage.hide();
                        //         ajaxData.navIndex = index;
                        //         ajaxData.SetSession();
                        //         clearTimeout(timeOutClock);
                        //         timeOutClock = setTimeout(function () {
                        //             sfddjIndex.oSlidePageMain.slideTo(0, 100);
                        //
                        //         },1300)
                        //
                        //         myPub.locationHref('https://m.sfddj.com/returnCash/index');
                        //         // sfddjIndex.oSlidePageMain.slideTo(0, 100);
                        //         // sfddjIndex.SildeNavScrollDis(0, function() {
                        //         // });
                        //
                        //         return;
                        //     }
                        //
                        // }
                        // // 请求加载广告
                        // else {
                        //     // myAdsModel.adsAjax.AdsAjaxData(index, categoryNames);
                        //     // ajaxData.GoodsAjaxData(index, true, function () {
                        //     //     oLoadingPage.hide();
                        //     // });
                        // }

                        ajaxData.tabLoadOff[index] = false;
                    }
                    oSlidePageScroll.find('.js_slidePageMain').hide().eq(index).show();
                    ajaxData.HisScrollTop(index);
                    lazLoading.DestroyLazLoadingImg();
                    lazLoading.AddLazLoadingImg(oSlidePageScroll[index]);

                    // 设置导航索引
                    // if(oSlidePageScroll.eq(index).hasClass('memberCashBack')){
                    //     ajaxData.navIndex = 0
                    // }else {
                    ajaxData.navIndex = index;
                    // }


                    // }

                    ajaxData.SetSession();

                    _this.oSlidePageMain.attachEvents();
                }
            });
        },

        // 设置导航宽度和滚动
        SetSildeNavScroll: function () {
            var sumLiWidth = 0;
            var oSildNavLi = oSildeNavUl.find('li');
            return;
            oSildNavLi.each(function (i) {
                sumLiWidth += oSildNavLi.eq(i).outerWidth(true) + 0.5
            });

            oSildeNavUl.css({
                'width' : Math.ceil(sumLiWidth)
            });

            nDisScrollLi = parseInt( (oSildeNavScroll.width() - oSildeNavUl.outerWidth(true))/(oSildNavLi.length-1) );

            if(oSildeNavJRoll.obj === undefined) {
                oSildeNavJRoll.AddScroll(oSildeNavScroll[0], {
                    scrollY: false,
                    scrollX: true
                });
            }
            else {
                oSildeNavJRoll.ReScroll()
            }


        },

        // 导航滚动和页面同步
        SildeNavScrollDis: function (index, callBack) {
            //判断当前是否为专题页面,是的话则不存在这些组件
            if(typeof pageId != 'undefined'){
                return;
            }

            var _dis = 0;
            // 导航滚动
            if(index >= oSildeNavUl.find('li').length-3) {
                _dis = parseInt(oSildeNavScroll.width() - oSildeNavUl.width());
            }
            else if (index > 2) {
                _dis = nDisScrollLi * index
            }
            oSildeNavJRoll.ScrollTo(_dis, 0, 100);
            if(callBack)callBack();
        },

        // 滚动隐藏搜索
        ScrollPage: function () {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var minScrHeight = 300;

            _this.nHeaderHeight = parseInt(oHeader.outerHeight(true));
            _this.nSearchBoxHeight = parseInt(oSearchBox.outerHeight(true));
            _this.nSildeNavHeight = parseInt(oSildeNav.outerHeight(true));


            oSlidePageScroll.off('scroll');
            oSlidePageScroll.on('scroll', function () {
                var afterScroll = $(this).scrollTop();



                _this.navFixedFn(afterScroll);
                // 滚动页面距离底部300像素 延迟150毫秒加载数据
                clearTimeout(_this.time_Scroll);
                _this.time_Scroll = setTimeout(function() {

                    //

                    // console.log(afterScroll)
                    var index = ajaxData.navIndex;
                    // 设置缓存记录
                    ajaxData.pageSCroll[index] = afterScroll;

                    // 显示隐藏回到顶部侧边框
                    _this.ShowGoTop(afterScroll);
                    _this.ScrollHide(afterScroll);


                    // _this.navFixedFn(afterScroll);
                },250);
            })

        },


        //判断
        navFixedFn:function (scrollTop) {
            var $this = this;
            //导航流动固定
            $('.js_goodsNavBox').each(function (e) {
                $this.getNavScroll();
                // 判断当前导航后有没有导航
                var dbOff = $('.js_goodsNavBox').eq(e+1).length > 0 ? true : false;
                // 判断当前导航是否与下一个导航的位置
                var judgeMask = dbOff ? $('.js_goodsNavBox').eq(e).offset().top <= 5 &&  $('.js_goodsNavBox').eq(e+1).offset().top > $('.js_goodsNav ').eq(e).height() : $('.js_goodsNavBox').eq(e).offset().top <= 5 ;
                if(judgeMask){
                    $('.js_goodsNavBox').eq(e).find('.js_goodsNav').css('visibility','hidden');
                    $('.js_goodsNavOutside').eq(e).css({top: 0}).removeClass('hideGoodsNav').siblings('.js_goodsNavOutside').addClass('hideGoodsNav');

                }else {
                    $('.js_goodsNavBox').eq(e).find('.js_goodsNav').css('visibility','visible');
                    $('.js_goodsNavOutside').eq(e).addClass('hideGoodsNav');
                }
            });
        },

        // 页面滚动到哪个位置导航就要相应的滚动
        getNavScroll: function(){
            var _this = this;
            var oModules = $('.js_moduleArea');
            var styleArr = myAdsModel.adsHtml.navActiveStyArr;
            var navStyleArr = [];
            if(styleArr && styleArr.length>0){
                navStyleArr = styleArr.concat(styleArr)
            }
            oModules.each(function (index,el) {
                // 优先寻找文字导航的
                if($(el).offset().top<=100 && $(el).offset().top>0){
                    var str = $(el)[0].id;
                    var id = str.substring(4,100);
                    // 该模块是否在文字导航中存在
                    if($('.nav'+id).length>0){
                        var oTextNav = $('.js_goodsTextNav');
                        var dataIndex = $('.nav'+id).eq(0).attr('data-index');
                        for(var i = 0; i<oTextNav.length;i++){
                            oTextNav.eq(i).find('li').removeClass('active').css({color: navStyleArr[i].fontColor});
                            oTextNav.eq(i).find('li').eq(dataIndex).addClass('active').css({color:navStyleArr[i].selectedColor})
                        }
                        myAdsModel.adsHtml.oSildeNavJRoll.forEach(function (el) {
                            el.ScrollTo(-myAdsModel.adsHtml.scrollTextWidth[dataIndex],0,100)
                        })
                    }
                    else if($('.navImg'+id).length>0){  // 如不在文字导航 是否在图片导航
                        var oTextNavDom = $('.js_goodsImgNav');        // 所有的图片导航
                        var dataImgIndex = $('.navImg'+id).eq(0).attr('data-index');
                        for(var j = 0; j<oTextNavDom.length;j++){
                            oTextNavDom.eq(j).find('.js_mask').removeClass('active').css({display:'block'});
                            oTextNavDom.eq(j).find('.js_mask').eq(dataImgIndex).addClass('active').css({display:'none'});
                        }
                        myAdsModel.adsHtml.oSildeImgNavJRoll.forEach(function (el) {
                            el.ScrollTo(-myAdsModel.adsHtml.scrollImgWidth[dataImgIndex],0,100)
                        })
                    }

                }

            })
        },

        // 显示回到顶部按钮
        ShowGoTop: function (scrollTop) {
            scrollTop > 300 ? oSideBox.stop().animate({'right':0},300) : oSideBox.stop().animate({'right': '-3.5rem'},300);
        },

        // 页面滚动隐藏导航
        ScrollHide: function (scrollTop) {
            var _this = this;
            //console.log('scroll----:'+scrollTop);
            // 判断滚动距离隐藏搜索框和滚动方向 （不能提出成单独方法）
            if(scrollTop > _this.nHeaderHeight) {
                // oContain.css({'top':  _this.nSildeNavHeight});
                oHeader.css({'top': -_this.nSearchBoxHeight-1}).find('.js_sildeNav').addClass('active')
            }
            else {
                // oContain.css({'top':  _this.nHeaderHeight -1});
                oHeader.css({'top': 0}).find('.js_sildeNav').removeClass('active');
            }

        },

    }

    var ajaxData = {
        pagearr: [1],                   // 每个分页的翻页数
        pageSCroll: [0],                // 每个分页滚动高度
        tabLoadOff: [false],            // 左右滑动加载开关
        navIndex: 0,                    // 导航选中索引
        loadFinish: [false],            // 加载完成
        loadAdsCount: 0,                // 加载计数
        locScrollTime: null,
        lockScroll: function () {
            var _this = this;
            _this.loadAdsCount ++;
        },

        unlockScroll: function () {
            var _this = this;
            _this.loadAdsCount --;
            // 检测数据请求完后执行
            if(_this.loadAdsCount == 0){
                var navIndex = 0;
                if(sessionStorage.getItem("navIndex") != null) {
                    navIndex = sessionStorage.getItem("navIndex");
                }

                clearTimeout(_this.locScrollTime);
                _this.locScrollTime =  setTimeout(function () {
                    oLoadingPage.hide();
                    _this.HisScrollTop(navIndex);
                }, 50);
            }
        },

        // 设置商品数据
        GoodsAjaxData: function (index,isInit,fn) {
            var _this = this;
            var nowStart = 0;
            var nowLimit = 0;
            var oSlidePageScroll = $('.js_slidePageScroll');
            // console.log("index  " + index + "  isInit  " + isInit + "  page  " + ajaxData.pagearr[index]);

            if(index == 0 && isInit) {
                nowStart = perLimit;
                nowLimit = perLimit *  (ajaxData.pagearr[index] - 1);
            }else if(index == 0 && !isInit) {
                nowStart = perLimit * ajaxData.pagearr[index];
                nowLimit = perLimit;
                // if( ajaxData.pagearr[index] >= 2 ){
                //     nowStart = perLimit;
                //     nowLimit = perLimit *  (ajaxData.pagearr[index] - 1);
                // }else{
                //     nowStart = perLimit;
                //     nowLimit = perLimit;
                // }
            }else if(isInit){
                nowStart = 0;
                nowLimit = perLimit * ajaxData.pagearr[index];
            }else{
                nowStart = perLimit * ajaxData.pagearr[index];
                nowLimit = perLimit;
            }
            var dataUrl = BASE_URL;
            var data = {};
            if(index == 0){
                dataUrl += "/shop/goods/loadGoods";
                data = {groupName:GROUP_NAME,start:nowStart,limit:nowLimit};
            }else if(index <= categoryData.length){
                dataUrl += "/category/loadAll";
                data = {categoryId:categoryData[index-1],start:nowStart,limit:nowLimit};
            }else{
                return;
            }

            if(isInit) {
                _this.lockScroll()
            }

            G_JSON_POST(dataUrl,data,function (data) {
                if( data.length > 0 ) {
                    if(index == 0) {
                        connectHtml.GoodsLiHtml(data, index, 'showTwo')
                    } else {
                        connectHtml.GoodsLiHtml(data, index, 'showOne')
                    }
                    if(fn)fn()
                }

                if(data.length < nowLimit){
                    oSlidePageScroll.eq(index).find('.js_loadingBtn').hide().eq(0).show();
                    ajaxData.loadFinish[index] = true;
                }

            }, function () {
                // start
            }, function () {
                // end
                if(isInit) {
                    _this.unlockScroll()
                }
            });

        },

        // 历史数据定位
        HistoryInit : function (fn1, fn2) {
            var _this = this;
            if(sessionStorage.getItem("navIndex") != null) {
                _this.navIndex = sessionStorage.getItem("navIndex")*1;
                sfddjIndex.SildeNavScrollDis(0, function() {
                    sfddjIndex.oSlidePageMain.slideTo(_this.navIndex, 100);
                });
                _this.GetSessionData();
                if(fn1) fn1(_this.navIndex);
            }
            else {
                if(fn2) fn2();
            }
        },

        // 历史滚动高度
        HisScrollTop: function (index) {
            var oSlidePageScroll = $('.js_slidePageScroll');
            if(sessionStorage.getItem("pageSCroll") != null) {
                var pageSCrollNum = sessionStorage.getItem("pageSCroll").split(',');
                // oWrap.scrollTop(pageSCrollNum[index]*1);

                oSlidePageScroll.eq(index).scrollTop(pageSCrollNum[index]*1);
            }
        },

        // 设置历史定位
        SetSession: function () {
            var _this = this;
            sessionStorage.setItem("navIndex", _this.navIndex);
            sessionStorage.setItem("pagearr", _this.pagearr);
            sessionStorage.setItem("pageSCroll", _this.pageSCroll);
        },

        // 记录数据历史数据
        GetSessionData: function() {
            var _this = this;
            if(sessionStorage.getItem("pageSCroll") != null) {
                var pageNum = sessionStorage.getItem("pagearr").split(',');
                var pageSCrollNum = sessionStorage.getItem("pageSCroll").split(',');
                _this.navIndex = sessionStorage.getItem("navIndex")*1;
                for(var i=0; i<pageNum.length; i++) {
                    //设置单个数据页数
                    ajaxData.pagearr[i] = parseInt(pageNum[i]);
                    //设置页面的数据
                    ajaxData.pageSCroll[i] = parseInt(pageSCrollNum[i]);
                }
            }
        },


    }

    // 拼接HTML
    var connectHtml = {

        // 产品容器（并排和一排）
        GoodHtmlBox: function (data, bOff) {
            var _selet = bOff;          //showTwo 并排  showOne 是一排
            var shmtlBox = '';
            var shmtlLoad = '';
            var goodsOneClass = 'js_goods_showOne';
            var goodsTwoClass = 'active js_goods_showTwo';

            function  setGoodsHtmlBox(aClassName) {
                if(aClassName == goodsOneClass) {
                    shmtlLoad = '<div class="moreBtnBox">'+
                        '<p class="loadingBtn js_loadingBtn" style="display:none;"><a>没有更多</a></p>'+
                        '<p class="loadingBtn js_loadingBtn">'+
                        '<span class="icon_loading icoStyle icon-spinner3 myRotateRefresh"></span>'+
                        '<span>加载中</span>'+
                        '</p>'+
                        '</div>';
                }
                return shmtlBox =   '<div class="goods_showChangeBox '+ aClassName +'">'+
                    '<div class="goods_showChange">'+
                    '<ul class="goodsList clearfix js_goodsList"></ul>'+
                    '</div>'+
                    shmtlLoad +
                    '</div>';
            }

            if(_selet == 'showTwo') {
                return setGoodsHtmlBox(goodsTwoClass)
            }
            else if(_selet == 'showOne') {
                return setGoodsHtmlBox(goodsOneClass)
            }
            else {
                return setGoodsHtmlBox(goodsOneClass)
            }


        },

        // 并排产品列表
        GoodsLiHtml: function (data, iNow, showNum) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var shtml = '';
            var sfindClass = '';
            var _smallImgArg = smallImgArg;

            //  showNum == 'showTwo' ? sfindClass = 'js_goods_showTwo' : sfindClass = 'js_goods_showOne';

            if(showNum == 'showTwo') {
                sfindClass = 'js_goods_showTwo';
            }
            else {
                sfindClass = 'js_goods_showOne';
                _smallImgArg = smallImgArg200;

                // sAddCarHtml = '<p class="addCar js_addCar"><em class="icon-shopcar_small"></em></p>';
            }

            var oGoodsShowLi = oSlidePageScroll.eq(iNow).find('.'+ sfindClass +'');
            // 判断是否需要放入容器和标题
            if(oGoodsShowLi.length == 0) {
                // 插入产品容器
                oSlidePageScroll.eq(iNow).find('.js_slidePageMain').append(_this.GoodHtmlBox(data, showNum));
                oGoodsShowLi = oSlidePageScroll.eq(iNow).find('.'+ sfindClass +'');
                // _this.GoodHtmlBox = null;
                // 插入产品标题
                // oGoodsShowLi.prepend(myAdsModel.adsHtml.TitleHtml(data, 'time'))
            }

            for (var i=0; i<data.length; i++) {
                var goodsImgUrl = data[i].showImage != undefined ? (HTTP_IMAGE_URL + data[i].showImage) : (BASE_URL + '/static_v4/image/loadImg.jpg');
                shtml += '<li>' +
                    '<a class="BoxSelf" href="' + BASE_URL + '/h/goodspay/goodsView/' + data[i].goodsSn + '" data-growing-title="'+data[i].name+'">'+
                    '<figure>'+
                    '<img class="js_lazyImg" data-echo="' + goodsImgUrl + _smallImgArg +'" ' +
                    'src="' + BASE_URL + '/static_v4/image/loadImg.jpg">';
                if(data[i].firstGueeImagePath!=null && data[i].firstGueeImagePath!=''){
                    shtml += '<img src="'+data[i].firstGueeImagePath+'"alt="" class="quanpei"/>';
                };
                if(sfindClass == 'js_goods_showTwo'){
                    if(data[i].goodsLabels && data[i].goodsLabels != ""){
                        shtml += '<div class="verpromotionHot"><span>'+ data[i].goodsLabel +'</span><div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div></div>';
                    }
                }
                // '<i class="tip-info">' + data[i].discount + '</i>'+
                shtml += '</figure>'+
                    '<aside class="priceArea VBox Bflex1">'+
                    '<div class="Bflex1 priceArea_name">'+
                    '<h4>' ;
                if(sfindClass == 'js_goods_showOne'){
                    if(data[i].goodsLabels && data[i].goodsLabels != ""){
                        shtml += '<i class="promotionHotIcon">'+ data[i].goodsLabel +'</i>';
                    }
                }
                shtml +=  data[i].name + '</h4>'+
                    '<p class="smallFont_tip">' + data[i].title + '</p>'+
                    '</div>'+
                    '<div class="priceArea_price">'+
                    // '<i class="tip-info">' + data[i].discount + '</i>'+
                    '<p class="HBox priceAreaBox">';
                // '<span class="goodsPriceOld">￥' + data[i].oldPrice + '</span>'+
                if(data[i].isTuangou){
                    shtml +=  '<span class="goodsPrice">￥' + data[i].tuangouPrices + '</span>'+
                        '<span class="tuangouNum">/<span>￥' + data[i].salePrice + '</span></span>'
                }else{
                    shtml += '<span class="goodsPrice">￥' + data[i].salePrice + '</span>'
                }
                shtml +=               '</p>'+
                    '</div>'+
                    '<p class="addCar js_addCar" pid="' + data[i].productId + '"><em class="icon-shopcar_small"></em></p>';
                shtml +=       '</aside>'+
                    '</a>';
                if(sfindClass == 'js_goods_showOne'){
                    if(data[i].label && data[i].label != ''){
                        shtml += '<p class="promotionSale horpromotionSale">';
                        for(var j=0;j<data[i].labels.length;j++){
                            shtml += '<i>'+data[i].labels[j]+'</i>'
                        }
                        shtml += '</p>';
                    }
                }
                shtml +=  '</li>';
            }
            var oShtml = $(shtml);
            oGoodsShowLi.find('.js_goodsList').append(oShtml);
            if(showNum == 'showTwo') {
                myPub.SetImgHeight(oShtml);
            }
            lazLoading.DestroyLazLoadingImg();
            lazLoading.AddLazLoadingImg(oSlidePageScroll[iNow]);

            shtml = null;
            sAddCarHtml = null;
            data = null;
        },

        // 新人优惠券弹框
        newFriendHtml:function () {
            var shtml = '';

            shtml += '<div class="js_inviteAd layer_Ads layer_Ads_invite">'+
                '   <div class="layer_Adsinvite">'+
                '       <div class="layer_inviteImgBox">'+

                '               <div class="inviteIndexBg">'+
                '                   <img src="' + BASE_URL + '/static_v4/image/invite/invitenIdexF.png" alt="">'+
                '               </div>'+
                '               <div class="counponBg">'+
                '                   <div class="couOverflow">';
            if(counponNewData && counponNewData.length > 0){
                for(var i = 0;i < counponNewData.length; i++){
                    var beginDate = myPub.FormatDateTime(new Date(counponNewData[i].beginDate),'minDay','.');
                    var endDate = myPub.FormatDateTime(new Date(counponNewData[i].endDate),'minDay','.');
                    shtml += '                 <div class="counponSin">'+
                        '                           <div class="indexConBg">'+
                        '                               <img src="' + BASE_URL + '/static_v4/image/invite/IndexConBg.png" alt="">'+
                        '                           </div>'+
                        '                           <div class="indexConTex HBox BoxCenter">'+
                        '                               <div class="conTexLe">'+
                        '                                   <p class="conTexPrice">￥<span>'+counponNewData[i].costPrice+'</span></p>'+
                        '                                   <p class="conTexTerm">'+counponNewData[i].needPrice+'</p>'+
                        '                               </div>'+
                        '                               <div class="conTexRi Bflex1">'+
                        '                                   <p class="conTexDes">'+counponNewData[i].couponName+'</p>'+
                        '                                   <p class="conTexTime">'+beginDate+'-'+endDate+'</p>'+
                        '                               </div>'+
                        '                           </div>'+
                        '                       </div>';
                }
            }else{
                shtml +='<p class="nullCou">注册成功，优惠券将在7日内到帐</p>'
            }
            shtml +='                   </div>'+
                '               </div>'+

                '       </div>'+
                '       <div class="layer_inviteCloseBtn">'+
                '           <img class="js_layer_inviteCloseBtn" src="' + BASE_URL + '/static_v4/image/invite/inviteClose.png" alt="">'+
                '       </div>'+
                '   </div>'+
                '</div>';

            var oShtml = $(shtml);
            oWrap.append(oShtml);

            var oInviteClose = $('.js_layer_inviteCloseBtn'); // 新人优惠券关闭按钮
            // 关闭新人优惠券弹窗
            oInviteClose.hammer().off('tap');
            oInviteClose.hammer().on('tap', function (e) {
                $('.layer_Ads_invite').hide();
                sessionStorage.removeItem('judgeNew_friend');
                sessionStorage.removeItem('judgeNew_friend_coupons');
                e.preventDefault()
            });
        }

    }

});
